VERSION 5.00
Begin VB.Form frmConfig 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Configuration "
   ClientHeight    =   5760
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6735
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5760
   ScaleWidth      =   6735
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdUpdate 
      Caption         =   "&Update"
      Height          =   375
      Left            =   5400
      TabIndex        =   8
      Top             =   5280
      Width           =   1215
   End
   Begin VB.TextBox txtCON_EMAIL_PASSWORD 
      Height          =   285
      Left            =   1800
      TabIndex        =   3
      Text            =   "Text3"
      Top             =   960
      Width           =   4695
   End
   Begin VB.TextBox txtCON_EMAIL_USER 
      Height          =   285
      Left            =   1800
      TabIndex        =   2
      Text            =   "Text2"
      Top             =   600
      Width           =   4695
   End
   Begin VB.TextBox txtCON_EMAIL_ADDRESS 
      Height          =   285
      Left            =   1800
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   240
      Width           =   4695
   End
   Begin VB.DirListBox Dir2 
      Height          =   1215
      Left            =   240
      TabIndex        =   7
      Top             =   3840
      Width           =   6255
   End
   Begin VB.DriveListBox Drive2 
      Height          =   315
      Left            =   3960
      TabIndex        =   6
      Top             =   3480
      Width           =   2535
   End
   Begin VB.DirListBox Dir1 
      Height          =   1440
      Left            =   240
      TabIndex        =   5
      Top             =   1920
      Width           =   6255
   End
   Begin VB.DriveListBox Drive1 
      Height          =   315
      Left            =   4080
      TabIndex        =   4
      Top             =   1560
      Width           =   2415
   End
   Begin VB.TextBox txtIMAGE_DIR 
      Height          =   285
      Left            =   1560
      Locked          =   -1  'True
      TabIndex        =   11
      TabStop         =   0   'False
      Text            =   "Text2"
      Top             =   3480
      Width           =   2295
   End
   Begin VB.TextBox txtDATA_DIR 
      Height          =   285
      Left            =   1440
      Locked          =   -1  'True
      TabIndex        =   10
      TabStop         =   0   'False
      Text            =   "Text1"
      Top             =   1560
      Width           =   2535
   End
   Begin VB.Shape Shape2 
      Height          =   3735
      Left            =   120
      Top             =   1440
      Width           =   6495
   End
   Begin VB.Label Label5 
      Alignment       =   1  'Right Justify
      Caption         =   "Email Password"
      Height          =   255
      Left            =   240
      TabIndex        =   14
      Top             =   960
      Width           =   1455
   End
   Begin VB.Label Label4 
      Alignment       =   1  'Right Justify
      Caption         =   "Email User"
      Height          =   255
      Left            =   240
      TabIndex        =   13
      Top             =   600
      Width           =   1455
   End
   Begin VB.Label Label3 
      Alignment       =   1  'Right Justify
      Caption         =   "Email Address"
      Height          =   255
      Left            =   240
      TabIndex        =   12
      Top             =   240
      Width           =   1455
   End
   Begin VB.Shape Shape1 
      Height          =   1215
      Left            =   120
      Top             =   120
      Width           =   6495
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Caption         =   "Image Directory"
      Height          =   255
      Left            =   240
      TabIndex        =   9
      Top             =   3480
      Width           =   1215
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "Data Directory"
      Height          =   255
      Left            =   240
      TabIndex        =   0
      Top             =   1560
      Width           =   1095
   End
End
Attribute VB_Name = "frmConfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'==================================================================================
'Copyright (c) 2003, Andrew Jeremy Gargan (ajg@osite.co.za), Terence Leslie Van Zyl (tvz@osite.co.za)
'
'All rights reserved.
'
'Redistribution and use in source and binary forms, with or without modification,
'are permitted provided that the following conditions are met:
'
'Redistributions of source code must retain the above copyright notice, this list
'of conditions and the following disclaimer.
'
'Redistributions in binary form must reproduce the above copyright notice, this
'list of conditions and the following disclaimer in the documentation and/or other
'materials provided with the distribution.
'
'Neither the name of the <ORGANIZATION> nor the names of its contributors may be
'used to endorse or promote products derived from this software without specific
'prior written permission.
'
'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
'ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
'WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
'IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
'INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
'BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
'DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
'LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
'OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
'OF THE POSSIBILITY OF SUCH DAMAGE.
'===================================================================================

'TODO: Config global
'TODO: ADDRESS DETAILS

Private Sub set_data_dir()
    Dim lvarFSO As New FileSystemObject
    If gvarConfig.DataPath <> "" Then
        On Error Resume Next
        txtDATA_DIR = gvarConfig.DataPath
        If lvarFSO.DriveExists(Mid(txtDATA_DIR, 1, 1)) Then
            If lvarFSO.FolderExists(txtDATA_DIR) Then
                Dir1.Path = txtDATA_DIR
                If lvarFSO.FolderExists(txtDATA_DIR) Then
                    Drive1.Drive = Split(Dir1.Path, ":", 2)(0)
                End If
            Else
                gvarConfig.DataPath = VB.App.Path
            End If
        End If
    End If
    txtDATA_DIR.Text = gvarConfig.DataPath
End Sub

Private Sub set_image_dir()
    Dim lvarFSO As New FileSystemObject
    If gvarConfig.ImagePath <> "" Then
        On Error Resume Next
        txtIMAGE_DIR = gvarConfig.ImagePath
        If lvarFSO.DriveExists(Mid(txtIMAGE_DIR, 1, 1)) Then
            If lvarFSO.FolderExists(txtIMAGE_DIR) Then
                Dir2.Path = txtIMAGE_DIR
                If lvarFSO.FolderExists(txtIMAGE_DIR) Then
                    Drive2.Drive = Split(Dir2.Path, ":", 2)(0)
                End If
            Else
                gvarConfig.ImagePath = VB.App.Path
            End If
        End If
    End If
    txtIMAGE_DIR = gvarConfig.ImagePath
End Sub

Private Sub cmdUpdate_Click()
    'set values
    gvarConfig.DataPath = txtDATA_DIR
    gvarConfig.ImagePath = txtIMAGE_DIR
    gvarConfig.EmailUser = txtCON_EMAIL_USER
    gvarConfig.EmailPassword = txtCON_EMAIL_PASSWORD
    gvarConfig.EmailAddress = txtCON_EMAIL_ADDRESS
    
    gvarConfig.Save_Config
    
    MsgBox "Configuration Saved!", vbOKOnly, "Success!"
    'MsgBox gvarConfig.DataPath
    
    Exit Sub
errorhandler:
    On Error GoTo 0
End Sub

Private Sub Dir1_Change()
    txtDATA_DIR = Dir1.Path
End Sub

Private Sub Dir2_Change()
    txtIMAGE_DIR = Dir2.Path
End Sub

Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub

Private Sub Drive2_Change()
    Dir2.Path = Drive2.Drive
End Sub

Private Sub set_data()
    set_data_dir
    set_image_dir
End Sub

Private Sub clear_form()
    Dim lvarControl As Control
        For Each lvarControl In Controls
            If TypeName(lvarControl) = "TextBox" Then
                lvarControl.Text = ""
            ElseIf TypeName(lvarControl) = "CheckBox" Then
                lvarControl.Value = 0
            'ElseIf TypeName(lvarControl) = "ComboBox" And lvarControl.Tag <> "" Then
            '    lvarControl.Clear
            ElseIf TypeName(lvarControl) = "ComboBox" Then
                lvarControl.Clear
            ElseIf TypeName(lvarControl) = "ListBox" Then
                lvarControl.Clear
            ElseIf TypeName(lvarControl) = "CommandButton" Then
            End If
        Next
End Sub

Private Sub Form_Load()
    clear_form
    set_data
End Sub

